Document how Cocoa coordinate and monitor layout transforms to GDK work
authorKristian Rietveld <kris@gtk.org>
Sun, 15 Nov 2009 14:29:45 +0000 (15:29 +0100)
committerKristian Rietveld <kris@gtk.org>
Sun, 15 Nov 2009 14:29:45 +0000 (15:29 +0100)
gdk/quartz/gdkscreen-quartz.c
gdk/quartz/gdkwindow-quartz.c

index 58b1d552e6e123c1ecc10f787291518265caac04..38d150e55e6efb4baecab99a19903a842f99963d 100644 (file)
 #include "gdkprivate-quartz.h"
  
 
+/* A couple of notes about this file are in order.  In GDK, a
+ * GdkScreen can contain multiple monitors.  A GdkScreen has an
+ * associated root window, in which the monitors are placed.  The
+ * root window "spans" all monitors.  The origin is at the top-left
+ * corner of the root window.
+ *
+ * Cocoa works differently.  The system has a "screen" (NSScreen) for
+ * each monitor that is connected (note the conflicting definitions
+ * of screen).  The screen containing the menu bar is screen 0 and the
+ * bottom-left corner of this screen is the origin of the "monitor
+ * coordinate space".  All other screens are positioned according to this
+ * origin.  If the menu bar is on a secondary screen (for example on
+ * a monitor hooked up to a laptop), then this screen is screen 0 and
+ * other monitors will be positioned according to the "secondary screen".
+ * The main screen is the monitor that shows the window that is currently
+ * active (has focus), the position of the menu bar does not have influence
+ * on this!
+ *
+ * Upon start up and changes in the layout of screens, we calculate the
+ * size of the GdkScreen root window that is needed to be able to place
+ * all monitors in the root window.  Once that size is known, we iterate
+ * over the monitors and translate their Cocoa position to a position
+ * in the root window of the GdkScreen.  This happens below in the
+ * function gdk_screen_quartz_calculate_layout().
+ *
+ * A Cocoa coordinate is always relative to the origin of the monitor
+ * coordinate space.  Such coordinates are mapped to their respective
+ * position in the GdkScreen root window (_gdk_quartz_window_xy_to_gdk_xy)
+ * and vice versa (_gdk_quartz_window_gdk_xy_to_xy).  Both functions can
+ * be found in gdkwindow-quartz.c.  Note that Cocoa coordinates can have
+ * negative values (in case a monitor is located left or below of screen 0),
+ * but GDK coordinates can *not*!
+ */
+
 static void  gdk_screen_quartz_dispose          (GObject         *object);
 static void  gdk_screen_quartz_finalize         (GObject         *object);
 static void  gdk_screen_quartz_calculate_layout (GdkScreenQuartz *screen);
index 0a851e8475b7298c7eda459dc4048e7b128467a2..7b47e7fe4efad8f06a2fdb39ff1d56a5c3092d0a 100644 (file)
@@ -653,6 +653,7 @@ _gdk_quartz_window_is_ancestor (GdkWindow *ancestor,
 }
 
 
+/* See notes on top of gdkscreen-quartz.c */
 void
 _gdk_quartz_window_gdk_xy_to_xy (gint  gdk_x,
                                  gint  gdk_y,